package cn.jishiyu11.xeqb.activity.personalCenterActivitys.settingpage

import android.os.Bundle
import android.view.View
import android.widget.ImageView
import android.widget.TextView

import com.umeng.analytics.MobclickAgent

import cn.jishiyu11.xeqb.R
import cn.jishiyu11.xeqb.base.BaseActivity
import cn.jishiyu11.xeqb.utils.newIntent
import kotlinx.android.synthetic.main.act_help_center.*
import kotlinx.android.synthetic.main.tab_activity_fra.*

/**
 * Created by vvguoliang on 2017/6/28.
 * 帮助中心
 */
class HelpCenterActivity : BaseActivity(), View.OnClickListener {

    var lin: Boolean = false
    var loan_lin: Boolean = false
    var loan_success_lin: Boolean = false
    var loan_repayment_lin: Boolean = false
    var loan_order_lin: Boolean = false
    var loan_fail_lin: Boolean = false
    var loan_data_lin: Boolean = false
    var loan_data_safe_lin: Boolean = false
    var loan_repay_interest_lin: Boolean = false
    var loan_why_auditing_lin: Boolean = false
    var loan_why_cannot_lin: Boolean = false
    var loan_others_lin: Boolean = false

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.act_help_center)
        findViewById()
        initView()
    }

    override fun onClick(v: View) {
        when(v){
            title_image -> finish()
            title_complete -> newIntent<AttentionActivity>()
            help_application_lin -> {lin = isChecked(lin,help_application_linear,help_application_image)}
            help_application_loan_lin -> {loan_lin = isChecked(loan_lin,help_application_loan_linear,help_application_loan_image)}
            help_application_loan_success_lin ->{loan_success_lin = isChecked(loan_success_lin,help_application_loan_success_linear,help_application_loan_success_image)}
            help_application_loan_repayment_lin ->{loan_repayment_lin = isChecked(loan_repayment_lin,help_application_loan_repayment_linear,help_application_loan_repayment_image)}
            help_application_loan_order_lin ->{loan_order_lin = isChecked(loan_order_lin,help_application_loan_order_linear,help_application_loan_order_image)}
            help_application_loan_fail_lin ->{loan_fail_lin = isChecked(loan_fail_lin,help_application_loan_fail_linear,help_application_loan_fail_image)}
            help_application_loan_data_lin ->{loan_data_lin = isChecked(loan_data_lin,help_application_loan_data_linear,help_application_loan_data_image)}
            help_application_loan_data_safe_lin ->{loan_data_safe_lin = isChecked(loan_data_safe_lin,help_application_loan_data_safe_linear,help_application_loan_data_safe_image)}
            help_application_loan_repay_interest_lin ->{loan_repay_interest_lin = isChecked(loan_repay_interest_lin,help_application_loan_repay_interest_linear,help_application_loan_repay_interest_image)}
            help_application_loan_why_auditing_lin ->{loan_why_auditing_lin = isChecked(loan_why_auditing_lin,help_application_loan_why_auditing_linear,help_application_loan_why_auditing_image)}
            help_application_loan_why_cannot_lin ->{loan_why_cannot_lin = isChecked(loan_why_cannot_lin,help_application_loan_why_cannot_linear,help_application_loan_why_cannot_image)}
            help_application_loan_others_lin ->{loan_others_lin = isChecked(loan_others_lin,help_application_loan_others_linear,help_application_loan_others_image)}
        }
    }

    override fun findViewById() {
        findViewById<View>(R.id.title_image).visibility = View.VISIBLE
        findViewById<View>(R.id.title_image).setOnClickListener(this)
        val title_view = findViewById<TextView>(R.id.title_view)
        title_view.text = this.getString(R.string.setting_helpcenter)

        val aboutAs = findViewById<TextView>(R.id.title_complete)
        aboutAs.visibility = View.VISIBLE
        aboutAs.setText(R.string.name_loan_personal_help_center_aboutas)
        aboutAs.setOnClickListener(this)
    }

    override fun initView() {
        title_image.setOnClickListener(this)
        title_image.visibility = View.VISIBLE
        title_view.setText(R.string.setting_helpcenter)
        title_complete.setText(R.string.name_loan_personal_help_center_aboutas)
        title_complete.visibility = View.VISIBLE
        title_complete.setOnClickListener(this)
        help_application_lin.setOnClickListener(this)
        help_application_loan_lin.setOnClickListener(this)
        help_application_loan_success_lin.setOnClickListener(this)
        help_application_loan_repayment_lin.setOnClickListener(this)
        help_application_loan_order_lin.setOnClickListener(this)
        help_application_loan_fail_lin.setOnClickListener(this)
        help_application_loan_data_lin.setOnClickListener(this)
        help_application_loan_data_safe_lin.setOnClickListener(this)
        help_application_loan_repay_interest_lin.setOnClickListener(this)
        help_application_loan_why_auditing_lin.setOnClickListener(this)
        help_application_loan_why_cannot_lin.setOnClickListener(this)
        help_application_loan_others_lin.setOnClickListener(this)
    }

    /**
     * 改变显示状态
     * */
    private fun isChecked(b: Boolean?, view: View,v: ImageView?): Boolean {
        var b = b
        if (b!!) {
            b = false
            view.visibility = View.GONE
            v?.setImageResource(R.mipmap.ic_loan_help_down)
        } else {
            b = true
            view.visibility = View.VISIBLE
            v?.setImageResource(R.mipmap.ic_loan_help_up)
        }
        return b
    }



    override fun onResume() {
        super.onResume()
        MobclickAgent.onResume(this)
    }

    override fun onPause() {
        super.onPause()
        MobclickAgent.onPause(this)
    }

}
